// 获取当前时间
export const getCurrentTime = (): string => {
  const myDate = new Date()
  const year = myDate.getFullYear()
  const month = zero(myDate.getMonth() + 1)
  const day = zero(myDate.getDate())

  const hour = zero(myDate.getDate())
  const minite = zero(myDate.getMinutes())
  const second = zero(myDate.getSeconds())

  const week = getWeek(myDate.getDay())

  return `${year}年${month}月${day}日 ${week} ${hour}:${minite}:${second}`
}

// 小于10的，前边补0
const zero = (value: number):string => {
  if (value < 10) {
    return '0' + value
  }
  return value.toString()
}

// 获取当前星期几
const getWeek = (value: number): string => {
  switch (value) {
    case 0:
      return '星期日'
    case 1:
      return '星期一'
    case 2:
      return '星期二'
    case 3:
      return '星期三'
    case 4:
      return '星期四'
    case 5:
      return '星期五'
    case 6:
      return '星期六'
    default:
      return ''
  }
}
